public class Test {



    public static void main(String[] args) {
        Integer a = 127;
        Integer b = 127;

        Integer a1 = 128;
        Integer b1 = 128;

        System.out.println(a == b);
        System.out.println(a1 == b1);


    }

    public static void main8(String[] args) {
        String s =  "a";
        System.out.println(s);
        s += "bc";
        System.out.println(s);
    }

    public static void main7(String[] args) {

        //通过 += 拼接字符串
        long start = System.currentTimeMillis();
        String s = "";
        for(int i = 0; i < 10000; i++){
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);

        //通过  StringBuilder 拼接字符串
        start = System.currentTimeMillis();
        StringBuilder stringBuilder = new StringBuilder();
        for(int i = 0; i < 10000; i++){
            stringBuilder.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end-start);

        //通过 stringBuffer 拼接字符串
        start = System.currentTimeMillis();
        StringBuffer stringBuffer = new StringBuffer();
        for(int i = 0; i < 10000; i++){
            stringBuffer.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end-start);


    }

    public static void main6(String[] args) {
        String str = "    asfsaf        asd      ";
        //可去除两边的空格
        System.out.println(str.trim());
        System.out.println(str.toUpperCase());
        System.out.println(str);
        str = "ABUIA";
        System.out.println(str.toLowerCase());
    }

    public static void main5(String[] args) {

        // \\ 是转义成 \
        String str = "192\\168\\0\\1";
        System.out.println(str);
        System.out.println(str.substring(4));

        //左闭右开
        System.out.println(str.substring(4,6));

        //这里要用到正则表达式
        String[] strings = str.split("\\\\");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static void main4(String[] args) {
        String str = "192.168.1.1";
        //对于 . 号这种特殊字符，必须进行转义
        String[] strings = str.split("\\.");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static void main3(String[] args) {

        String str = "name=zhangsan&age=10";
        String[] strings = str.split("&");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static void main2(String[] args) {

        String str = "abvcfgabvcfabcfdv";

        //替换全部
        String ret = str.replace("ab","qwer");
        System.out.println(ret);

        ret = str.replaceAll("ab","qwer");
        System.out.println(ret);

        //只替换第一个
        ret = str.replaceFirst("ab","q2e");
        System.out.println(ret);
    }

    public static void main1(String[] args) {

        String str1 = "abcde";
        System.out.println(str1.charAt(2));
        System.out.println(str1.indexOf("cd"));
        System.out.println(str1.lastIndexOf("b"));
        String a = String.valueOf(1234);
        System.out.println(a);

        //字符串转字符数组
        char[] chars = str1.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            System.out.print(chars[i]);
        }

        System.out.println();

        String s = String.format("%d-%d-%d",1999,9,19);
        System.out.println(s);

    }

}
